package com.rjwh.dingdong.client.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.aishua.lib.utils.AsStrUtils;
import com.bumptech.glide.Glide;
import com.rjwh.dingdong.client.R;
import com.rjwh.dingdong.client.bean.localbean.SysLoginBabylistBean;
import com.rjwh.dingdong.client.util.ViewHolder;
import com.rjwh.dingdong.client.widget.RoundImageView;
import com.wby.base.AdapterBase;

/**
 * @author Kay
 * @ClassName MoreBabyInfoListLvAdapter
 * @Description
 * @date 2016-7-20
 * @history 2016-7-20 author: description:
 */
public class MoreBabyInfoListLvAdapter extends AdapterBase<SysLoginBabylistBean> {
    private Context context;

    public MoreBabyInfoListLvAdapter(Context context) {
        this.context = context;
    }

    @Override
    protected View getExView(int i, View view, ViewGroup viewGroup) throws Exception {
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.more_baby_info_list_item, null);
        }
        RoundImageView Headimg = ViewHolder.get(view, R.id.more_baby_info_list_item_img);
        TextView nameTv = ViewHolder.get(view, R.id.more_baby_info_list_item_name_tv);

        SysLoginBabylistBean sysLoginBabylistBean = mList.get(i);
        String babyavatar = sysLoginBabylistBean.getBabyavatar();
        String babyname = sysLoginBabylistBean.getBabyname();
        String chief = sysLoginBabylistBean.getChief();

        if (!AsStrUtils.isEmpty(babyavatar)) {
            Glide.with(context).load(sysLoginBabylistBean.getBabyavatar()).dontAnimate().placeholder(R.drawable.icon_defult_avatar).error(R.drawable.icon_defult_avatar).into(Headimg);
        }
        if (!AsStrUtils.isEmpty(babyname)) {
            nameTv.setText(babyname);
            if (chief.equals("1")) {
                nameTv.setTextColor(context.getResources().getColor(R.color.yellow));
            } else {
                nameTv.setTextColor(context.getResources().getColor(R.color.content_aux_text_color));
            }
        }

        return view;
    }

    @Override
    protected void onReachBottom() {

    }
}
